/**
 * @file connection.c
 * @brief Short description of this file.
 *
 * Complete description of this file.
 *
 * @date Apr 20, 2012
 * @author Francesco Corvino
 */
#include "connection.h"

void Connection_init(Connection *c, char *addr, char *port){
	/// - Alloco lo spazio necessario per address
	if((c->address = malloc(strlen(addr)+1))==NULL){
		c->address = addr;
	} else {
		strcpy(c->address, addr);
	}
	/// - Alloco lo spazio necessario per port
	if((c->port = malloc(strlen(port)+1))==NULL){
		c->port = port;
	} else {
		strcpy(c->port,port);
	}
	/// - Inizializzo i restanti valori
	c->sd = -1;
	memset(&(c->dataProtocol),0,sizeof(HiddenType));
}

/**
 * @brief Elimina una connessione liberando la memoria occupata.
 *
 * @param c Connessione da eliminare.
 */
void Connection_destroy(Connection *c){
	free(c->address);
	free(c->port);
	HiddenType_destroy(&(c->dataProtocol));
}

void* Connection_getReport(Connection *c){
	return NULL;
}
